package controllers;

import classes.players.Generic;
import classes.players.Player;
import game.Game;

public class GameControler {

	private static int turn = 1;
	private static int actions = 1;
	
	public static int getActions() {
		return actions;
	}
	
	public static int getTurn() {
		return turn;
	}

	public static void doAction() {
		if (actions == 4) {
			changeTurn();
			actions = Game.getNumberOfActions();
		} else {
			actions++;
		}
	}

	public static void changeTurn() {
		if (turn == Game.getNumberOfPlayers()) {
			turn = 1;
		} else {
			turn++;
		}
	}
	
	public void addPlayer(String sessionID, String username) {
		Game.getInstance().getPlayers().put(sessionID, generateRandomRole(username));
	}

	private static Player generateRandomRole(String username) {
		//TODO Generate random role
		return new Generic(username, (Game.getInstance().getTurnIndex() + 1));
	}

}
